﻿using GalaSoft.MvvmLight;
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.IsolatedStorage;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;

namespace TFSUtils.ViewModel
{
    public class BaseViewModel : ViewModelBase
    {
        public virtual void SerialiseMe()
        {
            using (var store = IsolatedStorageFile.GetUserStoreForApplication())
            {
                using (var stream = new IsolatedStorageFileStream("data.txt", FileMode.Create, FileAccess.Write, store))
                {
                    var serializer = new XmlSerializer(this.GetType());
                    serializer.Serialize(stream, this);
                }
            }
        }

        public override void Cleanup()
        { 	 
            SerialiseMe();
            base.Cleanup();
        }
    }
}
